package com.csot.ry.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.csot.common.annotation.Log;
import com.csot.common.core.controller.BaseController;
import com.csot.common.core.domain.AjaxResult;
import com.csot.common.enums.BusinessType;
import com.csot.ry.domain.TZtIdleIp;
import com.csot.ry.service.ITZtIdleIpService;
import com.csot.common.utils.poi.ExcelUtil;
import com.csot.common.core.page.TableDataInfo;

/**
 * 中泰空闲ipController
 * 
 * @author csot
 * @date 2025-07-20
 */
@RestController
@RequestMapping("/zt/idleip")
public class TZtIdleIpController extends BaseController
{
    @Autowired
    private ITZtIdleIpService tZtIdleIpService;

    /**
     * 查询中泰空闲ip列表
     */
    @PreAuthorize("@ss.hasPermi('zt:idleip:list')")
    @GetMapping("/list")
    public TableDataInfo list(TZtIdleIp tZtIdleIp)
    {
        startPage();
        List<TZtIdleIp> list = tZtIdleIpService.selectTZtIdleIpList(tZtIdleIp);
        return getDataTable(list);
    }

    /**
     * 导出中泰空闲ip列表
     */
    @PreAuthorize("@ss.hasPermi('zt:idleip:export')")
    @Log(title = "中泰空闲ip", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TZtIdleIp tZtIdleIp)
    {
        List<TZtIdleIp> list = tZtIdleIpService.selectTZtIdleIpList(tZtIdleIp);
        ExcelUtil<TZtIdleIp> util = new ExcelUtil<TZtIdleIp>(TZtIdleIp.class);
        util.exportExcel(response, list, "中泰空闲ip数据");
    }

    /**
     * 获取中泰空闲ip详细信息
     */
    @PreAuthorize("@ss.hasPermi('zt:idleip:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tZtIdleIpService.selectTZtIdleIpById(id));
    }

    /**
     * 新增中泰空闲ip
     */
    @PreAuthorize("@ss.hasPermi('zt:idleip:add')")
    @Log(title = "中泰空闲ip", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TZtIdleIp tZtIdleIp)
    {
        return toAjax(tZtIdleIpService.insertTZtIdleIp(tZtIdleIp));
    }

    /**
     * 修改中泰空闲ip
     */
    @PreAuthorize("@ss.hasPermi('zt:idleip:edit')")
    @Log(title = "中泰空闲ip", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TZtIdleIp tZtIdleIp)
    {
        return toAjax(tZtIdleIpService.updateTZtIdleIp(tZtIdleIp));
    }

    /**
     * 删除中泰空闲ip
     */
    @PreAuthorize("@ss.hasPermi('zt:idleip:remove')")
    @Log(title = "中泰空闲ip", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tZtIdleIpService.deleteTZtIdleIpByIds(ids));
    }
}
